package com.rmdjzz.slmmn.pojo.result;

import lombok.Data;
import lombok.NoArgsConstructor;


/**
 * 结果集
 * @作者 张绍鑫
 * @创建时间 2023/5/26
 */
@NoArgsConstructor
@Data
public class Result<T> {
    private Integer code;
    private String msg;
    private T data;

    public Result(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Result(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    /**
     * 响应成功
     * @return
     */
    public static Result ok(){
        return new Result(200,"成功");
    }
    public static Result ok(String msg){
        return new Result(200,msg);
    }
    public static Result ok(Object data){
        return new Result(200,"成功",data);
    }
    public static Result ok(String msg,Object data){
        return new Result(200,msg,data);
    }

    /**
     * 响应失败
     * @return
     */
    public static Result fail(){
        return new Result(300,"失败");
    }
    public static Result fail(String msg){
        return new Result(300,msg);
    }
    public static Result fail(Object data){
        return new Result(300,"失败",data);
    }
}
